
import log from '@dfeidao/atom-nodejs/logger/log';

import query from '@dfeidao/atom-nodejs/db/query';

import { systemid } from '../atom/config';

import { IncomingHttpHeaders } from 'http';

// interface Message {
// 	// cookie: {
// 	// 	uk: string;
// 	// 	[key: string]: string
// 	// };
// 	// urls: {
// 	// 	base: string;
// 	// 	origin: string;
// 	// 	url: string;
// 	// };
// 	// query: {};
// 	// params: {};
// 	// headers: {};
// 	// captcha: string;
// }
interface Message {
	filter: {};
	asc: string[];
	desc: string[];
	page_size: number;
	page_no: number;
}


interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:ready-det/s001,action_id:' + action_id);
	// const sql = 'select _id,commodity_name,location_name,need_pick_num from pick_detail'
	const { exec, prepare } = query(action_id, session_id, systemid);
	prepare('pick_detail', ['_id', 'commodity_name', 'location_name', 'need_pick_num'], message.filter, message.page_size, message.page_no, [], []);
	const [data] = await exec();

	log('Service end path:ready-det/s001,action_id:' + action_id);



	return {
		data: [data]
	};
}
